package com.lgy.message;

import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

//@Component
//@EnableBinding(Sink.class)
//public class StreamReceiver {
//
//    @StreamListener(Sink.INPUT)
//    public void input(Message<String> message) {
//        System.out.println("接收到的消息: ===================" + JSONObject.toJSONString(message));
//    }
//
//
//}
@Component
@EnableBinding(StreamInput.class)
public class StreamReceiver {

    @StreamListener(StreamInput.INPUT)
    @SendTo(StreamInput.INPUT2)
    public String input(Object message) {
        System.out.println("接收到的消息: ===================" + JSONObject.toJSONString(message));
        return "消费完成";
    }

    @StreamListener(StreamInput.INPUT2)
    public void input2(String message) {
        System.out.println(message);
    }
}